<template>
  <div class="bigBoard">
    <div class="nav-menu-item" @click="tDashBoard">
      <Icon
        color="#c6e3ff"
        class="nav-menu-icon"
        name="iconfont icon-houtaiguanli-kufangguanli"
        size="22"
      />
      <!-- <span>设备地图</span> -->
      <div id="time">{{ state.time }}</div>
    </div>
    <div class="nav-menu-logo">
      <img src="@/assets/logo.png" alt="logo" />
      <span>设备看板-智能产线</span>
    </div>
    <!-- <text class="headerText">云天工业污染颗粒物排放监控平台</text> -->
    <Main />
  </div>
</template>
<script lang="ts" setup>
import Main from "@/layouts/backend/router-view/main.vue";
import { useRouter } from "vue-router";
import { onBeforeUnmount, reactive } from "vue";
import useCurrentInstance from "@/utils/useCurrentInstance";
import { timeFormat } from "@/utils/common";
import { useIntervalFn } from "@vueuse/core";

const { proxy } = useCurrentInstance();
const tDashBoard = () => {
  proxy.eventBus.emit("ToDashBoard");
  proxy.eventBus.emit("clear");
};

const state: { time: string } = reactive({ time: "" });

const initTime = () => {
  state.time = timeFormat("", "yyyy-mm-dd hh:MM:ss");
};

const { pause, resume, isActive } = useIntervalFn(
  () => {
    initTime();
  },
  1000,
  {
    immediate: true,
  }
);

onBeforeUnmount(() => {
  pause();
});
</script>
<style lang="scss" scoped>
.bigBoard {
  width: 100%;
  height: 100%;
  position: relative;
  //dashboard布局el-main的样式
  .el-main {
    padding: 0 !important;
    // background-color: #101129 !important;
    background-image: url(../../../assets/boardImage/mainBg.png);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-color: black;
  }
  .nav-menu-logo {
    position: absolute;
    left: 15px;
    top: 10px;
    z-index: 10;
    width: 40%;
    display: flex;
    align-items: center;
    flex-direction: row;
    justify-content: flex-start;
    color: #fff;
    span {
      // font-family: FangSong;
      font-family: Roboto, Roboto;
      font-weight: 600;
      font-size: 1.1rem;
      padding-left: 0.625rem;
      letter-spacing: 10px;
      text-shadow: 0px 8px 8px rgba(0, 0, 0, 0.3);
      text-align: justified;
      font-style: normal;
      text-transform: none;
      font-style: oblique;
      color: #edf6ff;
    }
  }
  .nav-menu-item {
    position: absolute;
    right: 15px;
    top: 15px;
    z-index: 100;
    width: 100px;
    display: flex;
    align-items: center;
    flex-direction: row;
    color: #fff;
    font-weight: 600;
    justify-content: space-around;
    cursor: pointer;
    #time {
      position: absolute;
      width: 350px;
      align-items: center;
      right: 0;
      height: 28px;
      font-family: Roboto, Roboto;
      font-weight: bold;
      font-size: 20px;
      color: #acc9e6;
      line-height: 28px;
      letter-spacing: 3px;
      text-align: justified;
      font-style: normal;
      text-transform: none;
    }
    .icon {
      box-sizing: content-box;
      // border: 1px solid #37ebfd;
    }
    span {
      transition: all 0.9s;
    }
    span:hover {
      font-weight: bolder;
    }

    &:hover {
      .icon {
        animation: twinkle 0.3s ease-in-out;
      }
    }
  }
}
</style>
